package jlib.component.tool.skin.points.decorator {
	
	import jlib.component.tool.TransformMode;
	
	import flash.display.DisplayObject;
	import flash.display.Shape;
	
	import jlib.utils.MathUtil;

	/**
	 * @author Aitmdia Lab (Park Jong Hee)
	 */
	public class DecoratorFactory {
		
		protected var referMoveCursor:DisplayObject;
		protected var referRotateCursor:DisplayObject;
		protected var referSkewCursor:DisplayObject;
		protected var referSizeCursor:DisplayObject;
		
		public final function getSkin(skinName:String): DisplayObject
		{
			var skin:Shape = new Shape();
			switch(skinName) {
				case TransformMode.ROTATE:
					skin.graphics.beginFill( 0xffffff, 0 );
					skin.graphics.drawCircle(0, 0, 10);
				break;
				case TransformMode.SKEW_X:
					skin.graphics.lineStyle(3, 0xffffff, 0.8);
					skin.graphics.beginFill( 0x444444,0.5 );
					skin.graphics.drawCircle(0,0,5);
				break;
				case TransformMode.SKEW_Y:
					skin.graphics.lineStyle(3, 0xffffff, 0.8);
					skin.graphics.beginFill( 0x444444,0.5 );
					skin.graphics.drawCircle(0,0,5);
					break;
				case TransformMode.SCALE_X :
					skin.graphics.lineStyle(3, 0xffffff, 0.8);
					skin.graphics.beginFill( 0x444444,0.5 );
					skin.graphics.drawCircle(0,0,5);
				break;
				case TransformMode.SCALE_Y :
					skin.graphics.lineStyle(3, 0xffffff, 0.8);
					skin.graphics.beginFill( 0x444444,0.5 );
					skin.graphics.drawCircle(0,0,5);
					break;
				case TransformMode.SCALE_BOTH: 
					skin.graphics.lineStyle(3, 0xffffff, 0.8);
					skin.graphics.beginFill( 0x444444,0.5 );
					skin.graphics.drawCircle(0,0,5);
				break;
				case TransformMode.MOVE:
					
					skin.graphics.beginFill( 0x444444, 0.5 );
					Drawer.triangle(skin.graphics, -6, 0, 3, MathUtil.toRadian(180));
					Drawer.triangle(skin.graphics, 6, 0, 3, 0);
					Drawer.triangle(skin.graphics, 0, -6, 3, MathUtil.toRadian(270));
					Drawer.triangle(skin.graphics, 0, 6, 3, MathUtil.toRadian(90));
					skin.graphics.lineStyle(2, 0xffffff, 0.8);
					skin.graphics.beginFill( 0x006699, 0.5 );
					skin.graphics.drawCircle(0,0,5);
					//skin.graphics.drawRoundRect(-3, -3, 7, 7, 2, 2);
				break;
			}
			return skin;
		}
		
		public final function getCursor(skinName:String): DisplayObject 
		{ 
			var cursor:DisplayObject;
			switch(skinName) {
				case TransformMode.MOVE: cursor = getMoveCursor();break;
				case TransformMode.ROTATE: cursor = getRotateCursor();break;
				case TransformMode.SKEW_X: cursor = getSkewCursor();break;
				case TransformMode.SKEW_Y: cursor = getSkewCursor();break;
				case TransformMode.SCALE_BOTH: cursor = getScaleCursor();break;
				case TransformMode.SCALE_X: cursor = getScaleCursor();break;
				case TransformMode.SCALE_Y: cursor = getScaleCursor();break;
			}
			return cursor;
		}
		
		public final function setMoveCursor(value:DisplayObject): void { referMoveCursor = value;	 }
		public final function setRotateCursor(value:DisplayObject): void { referRotateCursor = value;	 }
		public final function setSkewCursor(value:DisplayObject): void { referSkewCursor = value; }
		public final function setScaleCursor(value:DisplayObject): void { referSizeCursor = value; }
		
		protected final function getMoveCursor(): DisplayObject 
		{
			if(!referMoveCursor) return createMoveCursor();
			else return referMoveCursor;
		}
		
		protected final function getRotateCursor(): DisplayObject 
		{
			if(!referRotateCursor) return createRotateCursor();
			else return referRotateCursor;
		}
		
		protected final function getSkewCursor(): DisplayObject 
		{
			if(!referSkewCursor) return  createSkewCursor();
			else return referSkewCursor;
		}
		
		protected final function getScaleCursor(): DisplayObject 
		{
			if(!referSizeCursor) return createScaleCursor();
			else return referSizeCursor;
		}
		
		protected function createMoveCursor(): DisplayObject 
		{
			var result:Shape = new Shape();
			Drawer.moveCursor(result.graphics);
			return result;
		}
		
		protected function createRotateCursor(): DisplayObject 
		{ 
			var result:Shape = new Shape();
			Drawer.rotateCursor(result.graphics);
			return result;
		}
		
		protected function createSkewCursor(): DisplayObject 
		{
			var result:Shape = new Shape();
			Drawer.skewCursor(result.graphics);
			return result;
		}
		
		protected function createScaleCursor(): DisplayObject 
		{
			var result:Shape = new Shape();
			Drawer.scaleCursor(result.graphics);
			return result;
		}
		
		
	}//c
}
